/** 判断 path 是否为外链 */
export const isExternal = (path: string) => {
  const reg = /^(https?:|mailto:|tel:)/;
  return reg.test(path);
};

/** 判断 url 是否是 http 或 https */
export const isHttp = (url: string) => {
  return url.indexOf("http://") !== -1 || url.indexOf("https://") !== -1;
};

/**
 * 是否超链接
 */
export const isLink = (path: string) => {
  const regex = /^(https?:\/\/)?([a-zA-Z0-9.-]+\.[a-zA-Z]{2,})(:[0-9]{1,5})?(\/.*)?$/;
  return regex.test(path);
};

/**
 * 验证手机号
 * @type {RegExp}
 */
export const regPhone = (str:string)=> {
  const reg = /^(?:(?:\+|00)86)?1[3-9]\d{9}$/;
  return reg.test(str);
};
